﻿using EnvCheck.Models;
using EnvCheck.Services;
using EnvCheck.View.Existing;
using EnvCheck.View.Export;
using System.Collections.ObjectModel;
using System.Windows;


namespace EnvCheck.View
{
    public class MainViewModel : BaseViewModel
    {
        public ObservableCollection<BaseViewModel> AppVersionViewModel
            => GlobalViewModel.AppVersionViewModel;
        public MainViewModel()
        {
            //Task.Run(LoadAndCompare);
        }

        /// <summary>
        /// 加载各个版本的软件要求
        /// </summary>
        public void RegisterTabs(out int selected)
        {
            var versions = DatabaseService.GetAllVersions(out selected);
            Application.Current.Dispatcher.Invoke(() =>
            {
                AppVersionViewModel.Clear(); // 清空旧数据（可选）
                AppVersionViewModel.Add(new CurrentEnvViewModel()); // 导入 Tab

                foreach (var version in versions)
                {
                    AppVersionViewModel.Add(
                        new ReqSatisfactionViewModel()
                        {
                            AppVersion = version
                        }
                    );
                    OnPropertyChanged(nameof(AppVersionViewModel));
                }
            }); 
            
     

        }
        public override void Receive(string appName, string version)
        {
        }
        public override void ReportProgress(int current, int total)
        {

        }

    }
}
